#include <bits/stdc++.h>

#define ll long long
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
const int INF = 1e9;
using namespace std;
/*思考区

*/
void solve()
{
    int n = 0;
    int k = 0;
    cin >> n;
    vector<ll> a(n + 2,0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<ll> b(a);
    for (int i = n-1; i > 0; i--) {//将a[i]改为从后往前累加的和
        a[i] += a[i + 1];
    }
    for (int i = 2; i <= n; i++) {//b[i]为前i个的最大值
        if (b[i] < b[i - 1]) {
            b[i] = b[i-1];
        }
    }
    for (int k = 1; k <= n; k++) {//长度
        ll sum = 0;
        sum += b[n+1 - k];//加前面的1个最大值
        sum += a[n+1- k+1];
        cout << sum << ' ';
    }
    cout << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 0;
    cin >> t;
    while (t--)
        solve();
    return 0;
}